 package handling.login;

 import configs.ServerConfig;
 import handling.ServerType;
 import handling.login.handler.MapleBalloon;
 import handling.netty.ServerConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import tools.Pair;
 import tools.Quadruple;


 public class LoginServer
 {
/*  19 */   private static final Logger log = LogManager.getLogger(LoginServer.class);
/*  20 */   private static final List<MapleBalloon> lBalloon = new ArrayList<>();
/*  21 */   private static final HashMap<Integer, Quadruple<String, String, Integer, String>> loginAuth = new HashMap<>();
/*  22 */   private static final HashMap<String, Pair<String, Integer>> loginAuthKey = new HashMap<>();
   private static short port;
   private static ServerConnection init;
/*  25 */   private static Map<Integer, Integer> load = new HashMap<>();

   private static String serverName;
/*  28 */   private static int usersOn = 0; private static String eventMessage; private static byte flag;
   private static boolean finishedShutdown = true;

   public static void putLoginAuth(int chrid, String ip, String tempIp, int channel, String mac) {
/*  32 */     loginAuth.put(Integer.valueOf(chrid), new Quadruple(ip, tempIp, Integer.valueOf(channel), mac));
   }

   public static Quadruple<String, String, Integer, String> getLoginAuth(int chrid) {
/*  36 */     return loginAuth.remove(Integer.valueOf(chrid));
   }

   public static void pubLoginAuthKey(String key, String account, int channel) {
/*  40 */     loginAuthKey.put(key, new Pair(account, Integer.valueOf(channel)));
   }

   public static Pair<String, Integer> getLoginAuthKey(String account, boolean remove) {
/*  44 */     if (remove) {
/*  45 */       return loginAuthKey.remove(account);
     }
/*  47 */     return loginAuthKey.get(account);
   }


   public static void addChannel(int channel) {
/*  52 */     load.put(Integer.valueOf(channel), Integer.valueOf(0));
   }

   public static void removeChannel(int channel) {
/*  56 */     load.remove(Integer.valueOf(channel));
   }

   public static void run_startup_configurations() {
/*  60 */     serverName = ServerConfig.LOGIN_SERVERNAME;
/*  61 */     eventMessage = "";
/*  62 */     flag = ServerConfig.LOGIN_SERVERFLAG;
/*  63 */     port = ServerConfig.LOGIN_PORT;
     try {
/*  65 */       init = new ServerConnection(port, -1, -1, ServerType.登录服务器);
/*  66 */       init.run();
/*  67 */       log.info("登录器服务器绑定端口: " + port + ".");
/*  68 */       log.info("当前设置最大在线: " + ServerConfig.LOGIN_USERLIMIT + " 人 默认角色数: " + ServerConfig.LOGIN_DEFAULTUSERLIMIT + " 人 自动注册: " + ServerConfig.WORLD_ONLYADMIN);
/*  69 */     } catch (Exception e) {
/*  70 */       throw new RuntimeException("登录器服务器绑定端口: " + port + " 失败", e);
     }
   }

   public static void shutdown() {
/*  75 */     if (finishedShutdown) {
       return;
     }
/*  78 */     log.info("正在关闭登录服务器...");
/*  79 */     init.close();
/*  80 */     finishedShutdown = true;
   }

   public static String getServerName() {
/*  84 */     return serverName;
   }

   public static String getTrueServerName() {
/*  88 */     return serverName.substring(0, serverName.length() - 3);
   }

   public static String getEventMessage() {
/*  92 */     return eventMessage;
   }

   public static void setEventMessage(String newMessage) {
/*  96 */     eventMessage = newMessage;
   }

   public static byte getFlag() {
/* 100 */     return flag;
   }

   public static void setFlag(byte newflag) {
/* 104 */     flag = newflag;
   }

   public static Map<Integer, Integer> getLoad() {
/* 108 */     return load;
   }

   public static void setLoad(Map<Integer, Integer> load_, int usersOn_) {
/* 112 */     load = load_;
/* 113 */     usersOn = usersOn_;
   }

   public static int getUserLimit() {
/* 117 */     return ServerConfig.LOGIN_USERLIMIT;
   }

   public static void setUserLimit(int newLimit) {
/* 121 */     ServerConfig.LOGIN_USERLIMIT = newLimit;
   }

   public static int getUsersOn() {
/* 125 */     return usersOn;
   }

   public static List<MapleBalloon> getBalloons() {
/* 129 */     return lBalloon;
   }

   public static boolean isShutdown() {
/* 133 */     return finishedShutdown;
   }

   public static void setOn() {
/* 137 */     finishedShutdown = false;
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\login\LoginServer.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */